<template>
    <!-- 电子巡更 -->
    <div class="electronic_patrol">
        <div class="patrol_num">
            <div>
                <div>
                    <img src="@/assets/image/patrolpoint.png" alt="" />
                </div>
                <div>
                    <span>巡更点数量</span>
                    <span>10</span>
                </div>
            </div>
            <div>
                <div>
                    <img src="@/assets/image/Patrolline.png" alt="" />
                </div>
                <div>
                    <span>巡更点数量</span>
                    <span>10</span>
                </div>
            </div>
        </div>
        <div class="patrol_segmentation">
            <div></div>
            <div>
                <span>今日巡更次数</span>
                <span>6</span>
            </div>
        </div>
        <div class="patrol_realtime">
            <div @click="patrolmodel">
                <span>实时巡更</span>
            </div>
        </div>
        <div class="patrol_plan">
            <CommonTitleComponent text="巡更计划"></CommonTitleComponent>
            <div class="patrol_plan_table">
                <div class="tabContent table-both">
                    <ul class="table-title">
                        <li>巡检编号</li>
                        <li>任务名称</li>
                        <li>巡检线路</li>
                        <li>巡检时间</li>
                    </ul>
                    <div class="span-height" id="table_box">
                        <ul class="table-column" id="table_ul">
                            <li v-for="(item, index) in state.tableList" :key="index">
                                <el-tooltip :content="item.sn" placement="top" effect="light">
                                    <span>{{ item.sn }}</span>
                                </el-tooltip>
                                <el-tooltip :content="item.name" placement="top" effect="light">
                                    <span>{{ item.name }}</span>
                                </el-tooltip>
                                <span class="table_checkout">查看</span>
                                <span>{{ item.time }}</span>
                            </li>
                        </ul>
                        <ul class="table-column" id="ul_copy"></ul>
                    </div>
                </div>
            </div>
        </div>
        <div class="patrolmodel"></div>
    </div>
</template>
<script lang="ts" setup>
import { reactive, onMounted ,ref} from 'vue';
import { EchartsMethods } from '@/chart/index';
import renderPopconfirmComponent from "@/components/common/Popconfirm";
import Textcompoents from "@/components/custom/safetySpy/modal/realtimePatrol/index.vue";
let scrollMove = null;
const state = reactive({
    tableList: [
        {
            sn: 'XJ20220454543545435',
            name: '任务一',
            time: '2022/06/21'
        },
        {
            sn: 'XJ2022033',
            name: '任务33',
            time: '2022/06/21'
        },
        {
            sn: 'XJ20220',
            name: '任务',
            time: '2022/06/21'
        },
        {
            sn: 'XJ20220',
            name: '任务一',
            time: '2022/06/21'
        },
        {
            sn: 'XJ20220',
            name: '任务一',
            time: '2022/06/21'
        },
        {
            sn: 'XJ20220',
            name: '任务一',
            time: '2022/06/21'
        },
        {
            sn: 'XJ20220',
            name: '任务一',
            time: '2022/06/21'
        },
        {
            sn: 'XJ20220',
            name: '任务一',
            time: '2022/06/21'
        },
        {
            sn: 'XJ20220',
            name: '任务一',
            time: '2022/06/21'
        }
    ]
});

const patrolmodel=()=>{
    renderPopconfirmComponent({ title: '实时巡检', showPop: true }, Textcompoents);
}

const scroll = (box, l1, l2) => {
    scrollMove && clearInterval(scrollMove);
    l2.innerHTML = l1.innerHTML;
    function scrollup() {
        if (box.scrollTop >= l1.offsetHeight) {
            box.scrollTop = 0;
        } else {
            box.scrollTop++;
        }
    }
    scrollMove = setInterval(scrollup, 60);
    box.onmouseover = function () {
        clearInterval(scrollMove);
    };
    box.onmouseout = function () {
        scrollMove = setInterval(scrollup, 60);
    };
};
onMounted(() => {
    let box = document.getElementById('table_box');
    let l1 = document.getElementById('table_ul');
    let l2 = document.getElementById('ul_copy');
    scroll(box, l1, l2);
});
</script>
<style scoped lang="scss">
.electronic_patrol {
    height: 93%;

    .patrol_num {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 16px;

        > div {
            width: calc(50% - 6px);
            display: flex;
            align-items: center;
            justify-content: space-between;

            &:nth-of-type(1) {
                margin-right: 12px;
            }

            > div {
                &:nth-of-type(1) {
                    width: 64px;
                    height: 64px;
                    margin-right: 6px;

                    img {
                        width: 100%;
                        height: 100%;
                    }
                }

                &:nth-of-type(2) {
                    width: calc(100% - 70px);

                    span {
                        display: inline-block;
                        width: 100%;
                        text-align: center;
                        height: 22px;
                        color: #ffffff;

                        &:nth-of-type(1) {
                            font-size: 12px;
                            margin-bottom: 4px;
                            background: url('@/assets/image/patrolpointback.png') no-repeat;
                            background-size: 100% 100%;
                            height: 22px;
                            line-height: 22px;
                        }

                        &:nth-of-type(2) {
                            font-size: 20px;
                            height: 28px;
                            line-height: 28px;
                            background: url('@/assets/image/patrolpointnumback.png') no-repeat;
                            background-size: 100% 100%;
                        }
                    }
                }
            }
        }
    }

    .patrol_segmentation {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 15px;

        > div {
            &:nth-of-type(1) {
                height: 31px;
                width: 68%;
                background: url('@/assets/image/patrolsnum.png') no-repeat;
                background-size: 100% 100%;
            }

            &:nth-of-type(2) {
                display: flex;
                align-items: center;
                justify-content: space-between;

                > span {
                    &:nth-of-type(1) {
                        font-size: 12px;
                        color: #ffffff;
                        display: inline-block;
                        margin-right: 15px;
                    }

                    &:nth-of-type(2) {
                        font-size: 20px;
                        color: #ffffff;
                        font-family: PangMenZhengDao;
                        background: linear-gradient(182deg, #41f6ff 0%, #07bfff 100%);
                        -webkit-background-clip: text;
                        -webkit-text-fill-color: transparent;
                    }
                }
            }
        }
    }

    .patrol_realtime {
        padding: 2px 0;
        margin-top: 6px;
        background: url('@/assets/image/patrolrealtimeback.png') no-repeat;
        background-size: 100% 100%;
        display: flex;
        justify-content: center;

        > div {
            width: 98px;
            text-align: center;
            padding: 5px 20px;
            background: url('@/assets/image/realtimeback.png') no-repeat;
            background-size: 100% 100%;

            > span {
                font-size: 12px;
                color: #ffffff;
                font-weight: bold;
                cursor: pointer;
                line-height: 35px;
                background: linear-gradient(182deg, #9fe7fb 0.68359375%, #0591fd 100%);
                -webkit-background-clip: text;
                -webkit-text-fill-color: transparent;
            }
        }
    }

    .patrol_plan {
        margin-top: 12px;
        height:46%;

        .patrol_plan_table {
            margin-top: 10px;
            height: 100%;

            .table-both {
                height: 100%;

                .table-title {
                    display: flex;
                    align-items: center;
                    justify-content: space-around;
                    background: transparent;
                    color: #fff;
                    font-size: 12px;
                    color: #84b3d8;
                    padding: 8px 0;
                }

                .span-height {
                    height: 96%;
                    overflow: hidden;
                }

                .table-column {
                    li {
                        display: flex;
                        justify-content: space-around;
                        font-size: 12px;
                        padding: 10px 6px;
                        color: #ffffff;
                        font-family: Source Han Sans CN;

                        span {
                            display: inline-block;
                            flex: 1;
                            text-align: center;
                            max-width: 25%;
                            white-space: nowrap;
                            text-overflow: ellipsis;
                            overflow: hidden;
                        }

                        .table_checkout {
                            color: #1b93fb;
                            cursor: pointer;
                        }
                    }
                }
            }
        }
    }
}
</style>
